package ${packageName};

<#list imports as import>
import ${import};
</#list>

/**
 * @ClassName:  CBiz${underlineToCamel(sourceTable?lower_case,true?string)}
 * @Description:TODO(商业实体对象:C${underlineToCamel(sourceTable?lower_case,true?string)}Entity对应提供的服务具体实现)
 * @author: 初始由代码生成器生成
 * @date:   ${.now}
 * @version V1.0
 * @Copyright: Copyright (c) ${.now ? string('yyyy')}
 * 申明：本内容未经授权,禁止外泄以及用于其他的商业项目.
 */
@Service
@CacheConfig(cacheNames="Biz${underlineToCamel(sourceTable?lower_case,true?string)}_Cache")
public class CBiz${underlineToCamel(sourceTable?lower_case,true?string)} implements IBiz${underlineToCamel(sourceTable?lower_case,true?string)} {

	@Autowired
    private COzBkHeaderRepository access;

	@Override
    @Cacheable()
	public EntityCollection getEntityCollection(Map<String,Object> filter) throws Exception {
        AccessParameter parameter = new AccessParameter();
        parameter.getFilter().addAllEqual(filter);
        return access.searchEntityCollection(parameter);

	}

    @Override
    @Cacheable()
    public List<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity> getList(Map<String,Object> filter) throws Exception {
        AccessParameter parameter =  new AccessParameter();
        parameter.getFilter().addAllEqual(filter);
        return (List<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity>) access.searchEntityList(parameter);
    }


    @Override
    @Cacheable()
    public List<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity> getListBySql(CommandType commandType, String commandText, Object... obj) throws Exception {
        return (List<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity>) access.searchEntityListBySQL(commandType,commandText,obj);
    }

    @Override
    @Cacheable(key="#root.targetClass+':'+#root.methodName+':'+#filter+':'+#pageIndex+':'+#pageSize",unless = "#result.list.size() == 0")
    public  PageInfo<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity> getPageInfo(Map<String, Object> filter, Map<String, String> sorter,
            Integer pageIndex, Integer pageSize) throws Exception {

        AccessParameter parameter =  new AccessParameter();

        if(null != filter)
            parameter.getFilter().addAllEqual(filter);
        if(null != sorter)
            parameter.getSorter().add(sorter);

        parameter.setPageSize(pageSize);
        parameter.setPageIndex(pageIndex);

        return access.searchEntityPageInfo(parameter);
    }

    @Override
    @Cacheable(key = "#root.targetClass+':'+#root.methodName+':'+#parameter",unless = "#result.list.size() == 0")
    public PageInfo<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity> searchEntityPageInfo(AccessParameter parameter) throws Exception {
        return access.searchEntityPageInfo(parameter);
    }

    @Override
    @Cacheable(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,key="#id",unless = "#result==null")
	public  C${underlineToCamel(sourceTable?lower_case,true?string)}Entity getEntityById(String id) throws Exception {
        AccessParameter parameter = new AccessParameter();
        parameter.getFilter().addEqual(C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.PrimaryKey,id);
        return (C${underlineToCamel(sourceTable?lower_case,true?string)}Entity) access.searchEntity(parameter);
	}

    @Override
    @Cacheable(unless = "#result.size() == 0")
    public List<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity> getEntityListByIds(List<? extends Serializable> ids) throws Exception {
        return (List<C${underlineToCamel(sourceTable?lower_case,true?string)}Entity>) access.searchEntityListByIds(ids);
    }

	@Override
    @CachePut(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,key = "#p0.${underlineToCamel('${primaryKey[0].columnName}'?lower_case,false?string)}")
	public boolean add(C${underlineToCamel(sourceTable?lower_case,true?string)}Entity entity) throws Exception {
		return access.insert(entity);
	}

	@Override
    @CachePut(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,key = "#p0.${primaryKeyProperties}")
	public boolean update(C${underlineToCamel(sourceTable?lower_case,true?string)}Entity entity) throws Exception {
		return access.update(entity);
	}

    @Override
    @CachePut(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,key = "#p0.${primaryKeyProperties}")
    public boolean updateWithSelective(C${underlineToCamel(sourceTable?lower_case,true?string)}Entity entity) throws Exception {
        return access.updateWithSelective(entity);
    }

	@Override
    @CacheEvict(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,key = "#p0.${primaryKeyProperties}")
	public boolean delete(C${underlineToCamel(sourceTable?lower_case,true?string)}Entity entity) throws Exception {
		return access.delete(entity);
	}

	@Override
    @CacheEvict(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,key = "#p0")
	public boolean deleteByIdForSingle(Object keyValue) throws Exception {
		return access.deleteByIdForSingle(keyValue);
	}

    @Override
    @CacheEvict(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,allEntries = true)
    public boolean deleteBatchIds(List<? extends Serializable> ids, boolean recursive) throws Exception {
        return access.deleteBatchByIds(ids,recursive);
    }

    @Override
    @CacheEvict(value = C${underlineToCamel(sourceTable?lower_case,true?string)}Tags.TableName,allEntries = true)
    public boolean deleteBatchIds(List<? extends Serializable> ids) throws Exception {
        return deleteBatchIds(ids,true);
    }

    @Override
    public boolean hasExist(C${underlineToCamel(sourceTable?lower_case,true?string)}Entity entity) throws Exception {
        return getEntityById(entity.getJobOrderId()) != null;
    }

}